package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WmsWarehouseRack;
import com.ruoyi.system.domain.vo.SelectVo;
import com.ruoyi.system.mapper.WmsWarehouseRackMapper;
import com.ruoyi.system.service.IWmsWarehouseRackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 货架信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-17
 */
@Service
public class WmsWarehouseRackServiceImpl implements IWmsWarehouseRackService
{
    @Autowired
    private WmsWarehouseRackMapper wmsWarehouseRackMapper;

    /**
     * 查询货架信息
     *
     * @param rackId 货架信息主键
     * @return 货架信息
     */
    @Override
    public WmsWarehouseRack selectWmsWarehouseRackByRackId(Long rackId)
    {
        return wmsWarehouseRackMapper.selectWmsWarehouseRackByRackId(rackId);
    }

    /**
     * 查询货架信息列表
     *
     * @param wmsWarehouseRack 货架信息
     * @return 货架信息
     */
    @Override
    public TableDataInfo<WmsWarehouseRack> selectWmsWarehouseRackList(WmsWarehouseRack wmsWarehouseRack, PageQuery pageQuery)
    {
        Page<WmsWarehouseRack> page = wmsWarehouseRackMapper.selectWmsWarehouseRackList(pageQuery.build(),wmsWarehouseRack);
        return TableDataInfo.build(page);
    }

    /**
     * 新增货架信息
     *
     * @param wmsWarehouseRack 货架信息
     * @return 结果
     */
    @Override
    public int insertWmsWarehouseRack(WmsWarehouseRack wmsWarehouseRack)
    {
        wmsWarehouseRack.setCreateTime(DateUtils.getNowDate());
        return wmsWarehouseRackMapper.insertWmsWarehouseRack(wmsWarehouseRack);
    }

    /**
     * 修改货架信息
     *
     * @param wmsWarehouseRack 货架信息
     * @return 结果
     */
    @Override
    public int updateWmsWarehouseRack(WmsWarehouseRack wmsWarehouseRack)
    {
        wmsWarehouseRack.setUpdateTime(DateUtils.getNowDate());
        return wmsWarehouseRackMapper.updateWmsWarehouseRack(wmsWarehouseRack);
    }

    /**
     * 批量删除货架信息
     *
     * @param rackIds 需要删除的货架信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseRackByRackIds(Long[] rackIds)
    {
        return wmsWarehouseRackMapper.deleteWmsWarehouseRackByRackIds(rackIds);
    }

    /**
     * 删除货架信息信息
     *
     * @param rackId 货架信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseRackByRackId(Long rackId)
    {
        return wmsWarehouseRackMapper.deleteWmsWarehouseRackByRackId(rackId);
    }

    @Override
    public List<SelectVo> getWarehouseRackSelect(){
        return wmsWarehouseRackMapper.getWarehouseRackSelect();
    }

    @Override
    public List<SelectVo> getWarehouseRackSelectWarehouseAreaId(Long warehouseAreaId) {
        return wmsWarehouseRackMapper.getWarehouseRackSelectWarehouseAreaId(warehouseAreaId);
    }
}
